package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.search.service.EsManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <dl>
 * <dd>描述: ~节点业务逻辑实现</dd>
 * <dd>创建时间：  11:16 2020/4/5</dd>
 * <dd>创建人： zz</dd>
 * <dt>版本历史: </dt>
 * <pre>
 * Date         Author      Version     Description
 * ------------------------------------------------------------------
 * 2020/4/5      guodong       1.0        1.0 Version
 * </pre>
 * </dl>
 */
@RestController
@RequestMapping("manage")
public class EsManageController {

    @Autowired
    private EsManageService esManageService;

    /**
    * @Date: 11:25 2020/4/5
    * @Param: []
    * @return: com.changgou.entity.Result
    * @Description: 创建索引库
    **/
    @PostMapping("/createIndex")
    public Result createIndex() {
        esManageService.createIndex();
        return new Result();
    }

    /**
     * @Date: 11:25 2020/4/5
     * @Param: []
     * @return: com.changgou.entity.Result
     * @Description: 删除索引库
     **/
    @PostMapping("/delIndex")
    public Result delIndex() {
        esManageService.delIndex();
        return new Result();
    }

    /**
    * @Date: 11:33 2020/4/5
    * @Param: []
    * @return: com.changgou.entity.Result
    * @Description:
     *
     *  需求： 根据spuId导入sku数据
     *
     *  分析：
     *      1.需要changgou_service_goods_api 提供feign接口------>根据spuId导入sku数据
     *
     *
    **/
    @PostMapping("/importBySpuId/{spuId}")
    public Result importBySpuId(@PathVariable String spuId){
        esManageService.importBySpuId(spuId);
        return new Result();
    }

    /**
    * @Date: 14:14 2020/4/5
    * @Param: []
    * @return: com.changgou.entity.Result
    * @Description:  导入所有sku数据
    **/
    @PostMapping("/importAll")
    public Result importAll(){
        esManageService.importAll();
        return new Result();
    }

}
